package com.net.xpay.common.manager.impl.partner;

import com.google.common.base.Preconditions;
import com.net.common.dao.BasicMapper;
import com.net.common.dao.Page;
import com.net.xpay.common.dao.partner.PartnerUserFilingsMapper;
import com.net.xpay.common.domain.partner.PartnerUserFilings;
import com.net.xpay.common.manager.partner.PartnerUserFilingsManager;
import com.net.common.manager.AbstractManager;
import com.net.xpay.common.model.search.PartnerUserFilingsSearchModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;


@Component
public class PartnerUserFilingsManagerImpl extends AbstractManager<PartnerUserFilings> implements PartnerUserFilingsManager{

    @Autowired
    private PartnerUserFilingsMapper mapper;


    @Override
    protected BasicMapper<Long, PartnerUserFilings> getMapper() {
        return mapper;
    }



    @Override
    public List<PartnerUserFilings> search(PartnerUserFilingsSearchModel searchModel) {
        Preconditions.checkArgument(searchModel != null);
        Page page = new Page(searchModel);
        page.addOrder("audit_submit_time", "desc");
        page.addOrder("id", "desc");
        return nonEmptyList(mapper.search(searchModel, page));
    }

    @Override
    public long searchCount(PartnerUserFilingsSearchModel searchModel) {
        Preconditions.checkArgument(searchModel != null);
        return mapper.searchCount(searchModel);
    }
}
